/*
 * YUYV转换成bmp模块
 */
#ifndef YUVTOBMP_H
#define YUVTOBMP_H

#include "mydata.h"

/*BMP文件头*/
typedef struct tagBMPFILEHEADER
{
	u16 align;
	u16 bfType;		// the flag of bmp, value is "BM"
	u32 bfSize;		// size BMP file ,unit is bytes
	u32 bfReserved;		// 0
	u32 bfOffBits;		// must be 54
}BMPFILEHEADER;

/*BMP信息头*/
typedef struct tagBMPINFOHEADER
{
	u32 biSize;		// must be 0x28
	u32 biWidth;
	u32 biHeight;
	u16 biPlanes;		// must be 1
	u16 biBitCount;
	u32 biCompression;
	u32 biSizeImage;
	u32 biXPelsPerMeter;
	u32 biYPelsPerMeter;
	u32 biClrUsed;
	u32 biClrImportant;
}BMPINFOHEADER;

/*rgb24缓存 len: w*h*3 */
typedef struct __rgb24data
{
	int len;	/*rgb24缓存长度*/
	u8* buf;	/*rgb24缓存首地址*/
}RGB24;

/*bmp缓存 len: bf+bi+rgb */
typedef struct __bmpdata
{
	int len;	/*54+rgb24.len*/
	u8* buf;	/*bmp缓存首地址*/
}BMP;


/*
 *功能：YUYV转RGB24函数
 */
u8 * yuv_to_rgb24(u8 *yuv, u32 w, u32 h);
int get_rgb24_len();

/*RGB24转BMP*/
u8 *yuv_to_bmp(u8 *yuv, u32 w, u32 h);
int get_bmp_len();

/*初始化及分配空间*/
void init_conv(u32 w, u32 h);

/*分配空间*/
void uninit_conv();

#endif
